package uaem.tituaem.gui;

import java.io.IOException;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import uaem.tituaem.eventosgui.Eventos;
import uaem.tituaem.ftp.SubirArchivo;
import uaem.tituaem.operacionesFicheros.Escribir;

public class Principal extends javax.swing.JFrame {

    Eventos evt = new Eventos();
    public Principal() {
        initComponents();
        setLocationRelativeTo(null);
        this.deshabilitarBotones();
        evt.logIn(this);
        evt.logOut(this);
        
    }

    
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        tesisBtn = new javax.swing.JButton();
        subirArchivoBtn = new javax.swing.JButton();
        reportesBtn = new javax.swing.JButton();
        configuracionBtn = new javax.swing.JButton();
        acercaDeBtn = new javax.swing.JButton();
        salirBtn = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setMaximumSize(new java.awt.Dimension(600, 600));
        setMinimumSize(new java.awt.Dimension(600, 600));

        tesisBtn.setText("Tesis");
        tesisBtn.setMaximumSize(new java.awt.Dimension(130, 45));
        tesisBtn.setMinimumSize(new java.awt.Dimension(130, 45));
        tesisBtn.setPreferredSize(new java.awt.Dimension(130, 45));
        tesisBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tesisBtnActionPerformed(evt);
            }
        });

        subirArchivoBtn.setText("Subir Archivo");
        subirArchivoBtn.setMaximumSize(new java.awt.Dimension(130, 45));
        subirArchivoBtn.setMinimumSize(new java.awt.Dimension(130, 45));
        subirArchivoBtn.setPreferredSize(new java.awt.Dimension(130, 45));
        subirArchivoBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                subirArchivoBtnActionPerformed(evt);
            }
        });

        reportesBtn.setText("Reportes");
        reportesBtn.setMaximumSize(new java.awt.Dimension(130, 45));
        reportesBtn.setMinimumSize(new java.awt.Dimension(130, 45));
        reportesBtn.setPreferredSize(new java.awt.Dimension(130, 45));

        configuracionBtn.setText("Configuracion");
        configuracionBtn.setMaximumSize(new java.awt.Dimension(130, 45));
        configuracionBtn.setMinimumSize(new java.awt.Dimension(130, 45));
        configuracionBtn.setPreferredSize(new java.awt.Dimension(130, 45));

        acercaDeBtn.setText("Acerca de");

        salirBtn.setText("Salir");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(37, 37, 37)
                .addComponent(acercaDeBtn)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(salirBtn)
                .addGap(39, 39, 39))
            .addGroup(layout.createSequentialGroup()
                .addGap(234, 234, 234)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(configuracionBtn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(reportesBtn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tesisBtn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(subirArchivoBtn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(236, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(93, 93, 93)
                .addComponent(tesisBtn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(40, 40, 40)
                .addComponent(reportesBtn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(32, 32, 32)
                .addComponent(subirArchivoBtn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(42, 42, 42)
                .addComponent(configuracionBtn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 153, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(acercaDeBtn)
                    .addComponent(salirBtn))
                .addGap(31, 31, 31))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void tesisBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tesisBtnActionPerformed

        Tesis t = new Tesis(this, true);
        t.setVisible(true);
    }//GEN-LAST:event_tesisBtnActionPerformed

    private void subirArchivoBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_subirArchivoBtnActionPerformed
        Escribir esc=new Escribir();
        try {
            SubirArchivo sa=new SubirArchivo();
            esc.escribirPresentacionesFuturasSP();
            sa.subirArchivoPresentacionesFuturas();            
        } catch (IOException ex) {
            Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_subirArchivoBtnActionPerformed

    
    public void deshabilitarBotones()
    {
        subirArchivoBtn.setVisible(false);
        tesisBtn.setVisible(false);
    }
    
    public void habilitarBotones()
    {
        subirArchivoBtn.setVisible(true);
        tesisBtn.setVisible(true);
    }
    
    public boolean checkBotones(){
        
        boolean b=true;
        if(!subirArchivoBtn.isVisible()&&!tesisBtn.isVisible())
        {
            b=false;
        }
        
        return b;
    }
    
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Principal().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton acercaDeBtn;
    private javax.swing.JButton configuracionBtn;
    private javax.swing.JButton reportesBtn;
    private javax.swing.JButton salirBtn;
    private javax.swing.JButton subirArchivoBtn;
    private javax.swing.JButton tesisBtn;
    // End of variables declaration//GEN-END:variables
}
